<template>
    <div class="law">
        <div class="law-top mb-20">
            <Breadcrumb router />
            <div class="row f f-ac">
                <div class="row-title">检索：</div>
                <div class="f-1">
                    <el-input v-model="queryForm.search" placeholder="输入关键词" size="small" clearable style="width: 408px"
                        @change="search" />
                </div>
            </div>
        </div>
        <div class="law-bottom">
            <div class="law-box f f-js f-w">
                <div class="content-item mb-20" v-for="(i, k) in dataList" :key="k" @click="handleDetail(i)">
                    <div class="title line-1">{{ i.title || "-" }}</div>
                    <div class="content line-1 mt-20">{{ i.msg || "-" }}</div>
                    <img src="../../../assets/arrow-right.png" class="icon" />
                </div>
            </div>
            <Page-tool :size="queryForm.pageSize" :page="queryForm.currentPage" :total="total"
                @change-page="changePage" />
        </div>
    </div>
</template>

<script>
    import {
        heritageList,
    } from "@/utils/heritage/index.js";
    export default {
        data() {
            return {
                queryForm: {
                    search: "", // 搜索关键词
                    pageSize: 12, // 条数
                    currentPage: 1, // 页数
                },
                id: '',
                baseUrl: process.env.VUE_APP_BASE_API,
                total: 0, // 总数
                dataList: [],
            };
        },

        mounted() {},
        created() {
            this.id = this.$route.query.type
            this.queryForm.search = this.$route.query.search ? this.$route.query.search:''
            this.getList();
        },
        methods: {
            search() {
                this.queryForm.currentPage = 1;
                this.getList();
            },
            // 获取项目列表
            getList() {
                let that = this
                let data = {
                    heritage_category_id: that.id != 0 ? that.id : "",
                    title: that.queryForm.search,
                    type: '',
                    page: that.queryForm.currentPage,
                    limit: 12,
                    recommend: ''
                }
        
                heritageList(data).then((response) => {
                    that.dataList = response.data.list
                    that.total = response.data.count
                });
            },
            // 查看详情
            handleDetail(v) {
                this.$router.push({
                    path: "/cultural/lawDetails",
                    query: {
                        id: v.id,
                    },
                });
            },
            // 切换页数
            changePage(page) {
                this.queryForm.currentPage = page;
                this.getList();
            },
        },
    };
</script>

<style lang="scss" scoped>
    .law {
        width: 892px;
        min-height: 200px;
        margin: auto;

        .law-top {
            width: 100%;
            border-radius: 8px;
            padding: 20px;
            box-sizing: border-box;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(217, 217, 217, 0.3);

            .row {
                min-height: 36px;
                width: 100%;
                margin-top: 15px;

                &-title {
                    width: 90px;
                    color: #909090;
                    font-size: 14px;
                }
            }
        }

        .law-bottom {
            width: 100%;
            border-radius: 0 8px 8px 8px;
            padding: 20px;
            box-sizing: border-box;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(217, 217, 217, 0.3);

            .law-box {
                width: 100%;

                .content-item {
                    width: 416px;
                    height: 122px;
                    position: relative;
                    background-color: #fff;
                    border-radius: 20px;
                    padding: 30px;
                    box-sizing: border-box;
                    transition: all 0.5s;
                    box-shadow: 0 0 15px 0 rgba(225, 225, 225, 0.51);
                    position: relative;

                    &:nth-child(2n-1) {
                        margin-right: 20px;
                    }

                    &:hover {
                        cursor: pointer;
                        box-shadow: 0 0 15px 0 rgba(134, 134, 134, 0.7);
                    }

                    .title {
                        color: #313131;
                        font-size: 16px;
                        font-weight: 600;
                    }

                    .content {
                        color: #909090;
                        font-size: 14px;
                    }

                    >.icon {
                        width: 11px;
                        height: 17px;
                        position: absolute;
                        right: 20px;
                        bottom: 33px;
                    }
                }
            }
        }
    }
</style>